package com.qk.Dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.qk.my.pojos.Answer;

public class AnswerDao {
	private static SqlSession session;
	private static String statement;
	static {
		session = SqlSessionDao.getSession();
	}

	public static List<Answer> getAllAnswer() {
		statement = "com.qk.mapping.Answermapper.getAllAnswer";
		List<Answer> answer = session.selectList(statement);
		return answer;

	}

	public static Answer getAnswerById(int id) {
		statement = "com.qk.mapping.Answermapper.getAnswerById";
		Answer answer = session.selectOne(statement, id);
		return answer;
	}

	public static int insertAnswer(Answer answer) {
		statement = "com.qk.mapping.Answermapper.insertAnswer";
		int i = session.insert(statement, answer);
		session.commit();
		return i;
	}

	public static int updateAnswer(Answer answer) {
		statement = "com.qk.mapping.Answermapper.updateAnswer";
		int i = session.update(statement, answer);

		session.commit();
		return i;
	}
}
